<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
</head>
<body>
<div class="nav">
    <ul>
        <li>福利管理</li>
        <li>/</li>
        <li>福利列表</li>
    </ul>
</div>
<div class="toolbar">
    <input type="button" onclick="addBenefit()" value="添加福利"/>
</div>
<div class="list">
    <table id="tt"></table>
</div>
<script type="text/javascript">
    $(function () {
        $.get("/web/benefit", {op: "benefitList"}, function (data) {
            var table = $("#tt");
            table.empty();
            table.append("<tr><th><input type='checkbox' /></th>"
                + "<th>福利描述</th>" + "<th>操作</th></tr>");
            for (var x = 0; x < data.length; x++) {
                table.append("<tr>" + "<td><input type='checkbox' /></td>"
                    + "<td>" + data[x].benefitDesc + "</td>" + "<td><input type='button' value='编辑' onclick='updateBenefit(" + data[x].benefitId + ")'/>"
                    + "<input type='button' value='删除' onclick='deleteBenefit(" + data[x].benefitId + ")'/>" + "</td></tr>");
            }
        });
    });

    function deleteBenefit(id) {
        if (confirm("您确定要删除吗？")) {
            $.get("/web/benefit", {op: "benefitDelete", benefitId: id}, function (data) {
                $("#content").load("benefit/benefit-list.html");
                alert(data);
            });
        }
    }

    function updateBenefit(id) {
        updateId = id;
        $("#content").load("benefit/benefit-update.html");
    }

    function addBenefit() {
        $("#content").load("benefit/benefit-add.html");
    }
</script>
</body>
</html>